# -*- coding: utf-8 -*-
# owner: shenyi


from src.core import credentials

from alibabacloud_ecs20140526.client import Client as Ecs20140526Client
from alibabacloud_tea_openapi import models as open_api_models

class Client:
    
    @staticmethod
    def ecs_client():
        """
        使用AK&SK初始化账号Client
        @return: Client
        @throws Exception
        """
        aliyun_creds = credentials().aliyun()
        # 工程代码泄露可能会导致 AccessKey 泄露，并威胁账号下所有资源的安全性。以下代码示例仅供参考。
        # 建议使用更安全的 STS 方式，更多鉴权访问方式请参见：https://help.aliyun.com/document_detail/378659.html。
        open_api_config = open_api_models.Config(
            # 必填，请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。,
            access_key_id=aliyun_creds.get("access_key_id"),
            # 必填，请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。,
            access_key_secret=aliyun_creds.get("access_key_secret"),
            region_id=aliyun_creds.get("region_id"),
            endpoint=aliyun_creds.get("endpoint") # Endpoint 请参考 https://api.aliyun.com/product/Ecs
        )
        
        return Ecs20140526Client(open_api_config)